const path = require('path');
const copyPlugin = require('copy-webpack-plugin');
const htmlPlugin = require('html-webpack-plugin');
const fs = require('fs');

module.exports = {
    mode: 'production',
    entry: './src/app.js',//入口文件
    output: {//出口
        filename: 'app-[hash].js',
        path: path.resolve(__dirname, './dist/')//必须要写绝对路径
    },
    plugins: [//插件
        new htmlPlugin({
            title: '拉勾后台管理系统',
            template: './src/index.html',
            filename: 'index.html'
            // util: fs.readFileSync(path.resolve(__dirname, "./src/util/util.js")),
            // inject:'head'//注入到哪里
        }),
        //文件的拷贝
        new copyPlugin([
            {
                from: './src/public/', to: './public/'
            }
        ])
    ]
}